package com.example.parkdemo.parking

import androidx.lifecycle.MutableLiveData
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class ParkingViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val parkingSuccess by lazy { MutableLiveData<String>() }
    fun getPark() {
        executeNetWork(
            { apiService.parking() },
            parkingSuccess::postValue
        )
    }

    val delParkingSuccess by lazy { MutableLiveData<String>() }
    fun getDelParking(body: RequestBody) {
        executeNetWork(
            { apiService.delParking(body) },
            delParkingSuccess::postValue
        )
    }

    val getCarColorSuccess by lazy { MutableLiveData<String>() }
    fun getCarColor() {
        executeNetWork(
            { apiService.getCarColor() },
            getCarColorSuccess::postValue
        )
    }

    val AddSuccess by lazy { MutableLiveData<String>() }
    fun getAdd(body: RequestBody) {
        executeNetWork(
            { apiService.addParking(body) },
            AddSuccess::postValue
        )
    }
}